﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Collections.Generic
{
    /// <summary>
    /// IEnumerableExtension
    /// </summary>
    public static partial class IEnumerableExtension
    {
        /// <summary>
        /// 对 System.Collections.Generic.IEnumerable&lt;T&gt; 的每个元素执行指定操作。
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="this"></param>
        /// <param name="action">要对System.Collections.Generic.IEnumerable&lt;T&gt; 的每个元素执行的 System.Action&lt;T&gt;委托。</param>
        /// <returns>@this</returns>
        public static IEnumerable<T> ForEach<T>(this IEnumerable<T> @this, Action<T> action)
        {
            foreach (T t in @this)
            {
                action(t);
            }
            return @this;
        }
    }
}
